{{ template "head" .Global}}


<div id="table-datatables">
    <h4 class="header">主机信息列表
        <a href="#" class="btn dropdown-button waves-effect waves-light " style="float:right"
           onclick="salt_update_hosts()">更新主机信息</a>
    </h4>
</div>

<!--DataTables example-->
<div id="table-datatables">
    <div class="row">
        <div class="col s12 m12 l12">
            <table id="data-table-simple" class="responsive-table display" cellspacing="0">

                <thead>
                <tr>
                    <th>id</th>
                    <th>主机名</th>
                    <th>IP</th>
                    <th>CPU</th>
                    <th>内存</th>
                    <th>系统</th>
                    <th>selinux</th>
                    <th>虚拟程序</th>
                    <th>状态</th>
                    <th>添加时间</th>
                    <th>更新时间</th>

                </tr>
                </thead>

                <tbody>


                {{range $k,$v :=$.NodesAll}}
                <tr>
                    <td title="server_id:{{ $v.server_id }}">{{$v.id}}</td>
                    <td>{{$v.host}}</td>
                    <td title="MAC:{{$v.ipaddr_mac}}">{{$v.ipaddr}}</td>
                    <td>{{$v.num_cpus}} 核</td>
                    <td>{{$v.mem_total}} M</td>
                    <td title="内核:{{$v.kernelrelease}}">{{$v.os}} {{$v.osrelease}} </td>
                    <td>{{$v.selinux}}</td>
                    <td title="{{ $v.productname }}">{{ $v.virtual }}</td>
                    <td>{{ if eq $v.status "正常"}}<font color="lime"> {{ else if  eq $v.status "离线"}}<font color="#dc143c">{{ end }}{{$v.status}}</td>
                    <td>{{$v.add_time}}</td>
                    <td>{{$v.up_time}}</td>
                    <!--td>
                        <a a href="#nodecmd" class="btn dropdown-button waves-effect waves-light modal-trigger " onclick="showDiv({{$v.hostname}})">执行命令</a>
                    </td-->

                </tr>
                {{end}}
                </tbody>
            </table>
        </div>
    </div>
</div>

<script type="text/javascript">
    function showDiv(hostname){
        jQuery(jQuery('#nodecmd'));
            document.getElementById("cmd_hostname").value = hostname,
        alert(hostname);
    }
</script>

</div>
<!-- Floating Action Button -->
<div class="fixed-action-btn" style="bottom: 50px; right: 19px;">
    <a class="btn-floating btn-large">
        <i class="mdi-action-stars"></i>
    </a>
    <ul>
        <li><a href="css-helpers.html" class="btn-floating red"><i
                class="large mdi-communication-live-help"></i></a></li>
        <li><a href="app-widget.html" class="btn-floating yellow darken-1"><i
                class="large mdi-device-now-widgets"></i></a></li>
        <li><a href="app-calendar.html" class="btn-floating green"><i
                class="large mdi-editor-insert-invitation"></i></a></li>
        <li><a href="app-email.html" class="btn-floating blue"><i class="large mdi-communication-email"></i></a>
        </li>
    </ul>
</div>
<!-- Floating Action Button -->
</div>
<!--end container-->

</section>
<!-- END CONTENT -->

<div id="nodecmd" class="modal card deep-purple">
    <from>
    <div class="card-content white-text">
        <p class="card-title white-text darken-1">执行命令</p>
        <span class="btn-block">请确定服务器信息正确性</span>
        <!--<input type="text" class="form-control" id="cmd_id" name="cmd_id" readonly>-->
        <input type="text" class="form-control" id="cmd_hostname" name="cmd_hostname" readonly>
    </div>
    <div id="cmd_id">
        <!--<i class="material-icons prefix">cmd</i>-->
        <input id="cmdinfo"  type="text" class="materialize-textarea validate" length="120">
        <!--<textarea id="message4" class="materialize-textarea validate" length="120"></textarea>-->
        <label class="">cmd</label>
        <div class="card-action deep-purple darken-2 modal-footer">
            <button class="btn " type="submit" name="action">
                <i class="material-icons right modal-close">取消</i>
            </button>
            <button class="btn cyan waves-effect waves-light right" type="submit" >
                <a class="material-icons right" modal-action onclick="aaaa()">执行</a>
            </button>
        </div>
    </div>
    </from>
    <!--执行取消窗口-->

</div>

{{ template "foot" .Global}}
<script type="text/javascript" src="/statics/js/function.js"></script>
<!-- jQuery Library -->
<script type="text/javascript" src="/statics/js/plugins/jquery-1.11.2.min.js"></script>
<!--materialize js-->
<script type="text/javascript" src="/statics/js/materialize.min.js"></script>
<!--prism-->
<script type="text/javascript" src="/statics/js/plugins/prism/prism.js"></script>
<!--scrollbar-->
<script type="text/javascript" src="/statics/js/plugins/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<!-- data-tables -->
<script type="text/javascript" src="/statics/js/plugins/data-tables/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/statics/js/plugins/data-tables/data-tables-script.js"></script>
<!-- chartist -->
<script type="text/javascript" src="/statics/js/plugins/chartist-js/chartist.min.js"></script>
<!--sweetalert -->
<script type="text/javascript" src="/statics/js/plugins/sweetalert/sweetalert.min.js"></script>
<!--plugins.js - Some Specific JS codes for Plugin Settings-->
<script type="text/javascript" src="/statics/js/plugins.min.js"></script>
<!--custom-script.js - Add your own theme custom JS-->
<script type="text/javascript" src="/statics/js/custom-script.js"></script>
<script type="text/javascript">
    /*Show entries on click hide*/
    $(document).ready(function () {
        $(".dropdown-content.select-dropdown li").on("click", function () {
            var that = this;
            setTimeout(function () {
                if ($(that).parent().hasClass('active')) {
                    $(that).parent().removeClass('active');
                    $(that).parent().hide();
                }
            }, 100);
        });
    });
</script>
</body>

</html>